package com.sc.ifs.advert;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sc.dal.model.advert.Advert;
import com.sc.service.advert.AdvertService;
import com.sc.util.data.DataUtil;
import com.sc.util.exception.ExceptionEnum;

@Controller
@RequestMapping(value="/app/advert")
public class AppAdvertController {
	@Autowired
	private AdvertService advertService;
	@RequestMapping(value="getAdvertList")
	@ResponseBody
	public Map<String, Object> getAdvertList(Integer amount,String type){
		Map<String, Object> resultMap=new HashMap<String, Object>();
		try {
			List<Advert> advertList=advertService.getAdvertList(amount,type);
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS, advertList);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
		}
		return resultMap;
	}
}
